package structural.facade.custom.devices;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * 时钟
 */
public class Clock {

    public Calendar showTime() {
        Calendar c =  Calendar.getInstance();
        SimpleDateFormat sdf = new SimpleDateFormat("hh:MM:ss");
        System.out.println("当前时间： " + sdf.format(c.getTime()));
        return c;
    }

    public boolean isNight() {
        Calendar c = this.showTime();
        int h = c.get(Calendar.HOUR_OF_DAY);
        return  (h < 6 || h > 18);
    }

    public boolean isDay() {
        Calendar c = this.showTime();
        int h = c.get(Calendar.HOUR_OF_DAY);
        return  (h > 6 && h < 18);
    }
}
